]> dgit.raspbian.org Git - gnome-shell.git/commitdiff
st: Use consistent type for properties/getters
authorFlorian Müllner <fmuellner@gnome.org>
Wed, 22 Jan 2025 23:06:17 +0000 (00:06 +0100)
committerMarge Bot <marge-bot@gnome.org>
Wed, 12 Feb 2025 13:11:11 +0000 (13:11 +0000)
gjs now optimizes property accesses if possible, by calling the
corresponding getter/setter method. For this to work, the method
not only has to exist (obviously), but also match the type of
the corresponding property.

Both `Label` and `Entry` currently define their `clutter-text`
property as `Clutter.Text`, while the corresponding getter
returns the more generic `Clutter.Actor`.

Fix that so that both property and getter use the more specific type.

Part-of: <https://gitlab.gnome.org/GNOME/gnome-shell/-/merge_requests/3620>

src/st/st-entry.c
src/st/st-entry.h
src/st/st-label.c
src/st/st-label.h
src/st/st-password-entry.c

index d2b9c61cd47c5259e635c74753bd0f24ea375330..5ce08dfd247705c6fc0b44c3efea8ec57c8a13d3 100644 (file)
@@ -1165,12 +1165,16 @@ st_entry_set_text (StEntry     *entry,
  *
  * Returns: (transfer none): the #ClutterText used by @entry
  */
-ClutterActor*
+ClutterText *
 st_entry_get_clutter_text (StEntry *entry)
 {
+  StEntryPrivate *priv;
+
   g_return_val_if_fail (ST_ENTRY (entry), NULL);
 
-  return ((StEntryPrivate *)ST_ENTRY_PRIV (entry))->entry;
+  priv = st_entry_get_instance_private (entry);
+
+  return CLUTTER_TEXT (priv->entry);
 }
 
 /**
index b0958bbab17f1d079782186d5db494e63b218417..b627490823c201ef7bb40ab0ad74755f7f8a5709 100644 (file)
@@ -43,7 +43,7 @@ StWidget       *st_entry_new                (const gchar    *text);
 const gchar    *st_entry_get_text           (StEntry        *entry);
 void            st_entry_set_text           (StEntry        *entry,
                                              const gchar    *text);
-ClutterActor   *st_entry_get_clutter_text   (StEntry        *entry);
+ClutterText    *st_entry_get_clutter_text   (StEntry        *entry);
 
 void            st_entry_set_hint_text      (StEntry        *entry,
                                              const gchar    *text);
index fe88f19ea6ba4eb962ac49589bd38bc40177233b..164c5419c17dbf360595f6e173612ccfb3aa9da7 100644 (file)
@@ -429,12 +429,12 @@ st_label_set_text (StLabel     *label,
  * Returns: (transfer none): the #ClutterText used by #StLabel. The actor
  * is owned by the #StLabel and should not be destroyed by the application.
  */
-ClutterActor*
+ClutterText *
 st_label_get_clutter_text (StLabel *label)
 {
   g_return_val_if_fail (ST_LABEL (label), NULL);
 
-  return label->priv->label;
+  return CLUTTER_TEXT (label->priv->label);
 }
 
 
index 199a5a0066f07b840a0b13ca01cb142407127005..1c8d1581e53db2b93c9baffdfe562efd21749e6a 100644 (file)
@@ -44,7 +44,7 @@ StWidget *     st_label_new              (const gchar *text);
 const gchar *  st_label_get_text         (StLabel     *label);
 void           st_label_set_text         (StLabel     *label,
                                           const gchar *text);
-ClutterActor * st_label_get_clutter_text (StLabel     *label);
+ClutterText *  st_label_get_clutter_text (StLabel     *label);
 
 G_END_DECLS
 
index 3fe50082f0ab92293a100a05ba442493061dbaa0..b55d7b1daf6704c9b81914da98c0f063663d6719 100644 (file)
@@ -205,10 +205,10 @@ clutter_text_password_char_cb (GObject    *object,
                                gpointer    user_data)
 {
   StPasswordEntry *entry = ST_PASSWORD_ENTRY (user_data);
-  ClutterActor *clutter_text;
+  ClutterText *clutter_text;
 
   clutter_text = st_entry_get_clutter_text (ST_ENTRY (entry));
-  if (clutter_text_get_password_char (CLUTTER_TEXT (clutter_text)) == 0)
+  if (clutter_text_get_password_char (clutter_text) == 0)
     st_password_entry_set_password_visible (entry, TRUE);
   else
     st_password_entry_set_password_visible (entry, FALSE);
@@ -218,7 +218,7 @@ static void
 st_password_entry_init (StPasswordEntry *entry)
 {
   StPasswordEntryPrivate *priv = ST_PASSWORD_ENTRY_PRIV (entry);
-  ClutterActor *clutter_text;
+  ClutterText *clutter_text;
 
   priv->peek_password_icon = g_object_new (ST_TYPE_ICON,
                                            "style-class", "peek-password",
@@ -235,7 +235,7 @@ st_password_entry_init (StPasswordEntry *entry)
                            0);
 
   clutter_text = st_entry_get_clutter_text (ST_ENTRY (entry));
-  clutter_text_set_password_char (CLUTTER_TEXT (clutter_text), BLACK_CIRCLE);
+  clutter_text_set_password_char (clutter_text, BLACK_CIRCLE);
 
   st_entry_set_input_purpose (ST_ENTRY (entry), CLUTTER_INPUT_CONTENT_PURPOSE_PASSWORD);
 
@@ -316,7 +316,7 @@ st_password_entry_set_password_visible (StPasswordEntry *entry,
                                         gboolean         value)
 {
   StPasswordEntryPrivate *priv;
-  ClutterActor *clutter_text;
+  ClutterText *clutter_text;
 
   g_return_if_fail (ST_IS_PASSWORD_ENTRY (entry));
 
@@ -329,12 +329,12 @@ st_password_entry_set_password_visible (StPasswordEntry *entry,
   clutter_text = st_entry_get_clutter_text (ST_ENTRY (entry));
   if (priv->password_visible)
     {
-      clutter_text_set_password_char (CLUTTER_TEXT (clutter_text), 0);
+      clutter_text_set_password_char (clutter_text, 0);
       st_icon_set_icon_name (ST_ICON (priv->peek_password_icon), "view-conceal-symbolic");
     }
   else
     {
-      clutter_text_set_password_char (CLUTTER_TEXT (clutter_text), BLACK_CIRCLE);
+      clutter_text_set_password_char (clutter_text, BLACK_CIRCLE);
       st_icon_set_icon_name (ST_ICON (priv->peek_password_icon), "view-reveal-symbolic");
     }